package com.lei.view.configmgr;

import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.GridBagLayout;

import javax.swing.JPanel;

import com.lei.ife.ReLoadDateInterface;
import com.lei.util.XMLParse;
import com.lei.view.sys.MyGBC;

public class SQLSetPanel extends JPanel implements ReLoadDateInterface{

	private static final long serialVersionUID = 1L;
	private SingleSetPanel address,dbname,username,password,connum;

	public SQLSetPanel() {
		initImage();
		initFrame();
		initAssembly();
		addActionListenner();
		this.updateUI();
	}
	
	private void initImage() {

	}

	private void initFrame() {
		this.setLayout(new GridBagLayout());
		this.setVisible(true);
		this.setPreferredSize(new Dimension(0, 0));
		this.setOpaque(false);
	}
	
	private void initAssembly() {
		String[][] config = XMLParse.getSqlElements("db-set");
		for(int i = 0;i<config.length;i++){
			this.add(new SingleSetPanel(config[i][0] +":", config[i][1],config[i][2],"db-set"),new MyGBC(0, i, 1, 1).setFill(MyGBC.HORIZONTAL).setWeight(1, 0).setInsets(20, 10, 20, 10));
		}
		
	}
	
	private void reLoadAssembly(){
		this.removeAll();
		initAssembly();
		addActionListenner();
		this.repaint();
		this.updateUI();
	}
	
	private void addActionListenner() {
		
	}

	@Override
	public void reload(Object loadName) {
		if(loadName instanceof ReLoadDateInterface){
			reLoadAssembly();
		}
	}




}
